package net.com.sunkey.messagehandler;

import net.com.sunkey.protobuf.Protocol;
import net.com.sunkey.protobuf.UserPropertyUpdateRequest.UserPropertyUpdateRequestData;
import net.com.sunkey.serverlogic.Properties;
import net.com.sunkey.serverlogic.User;

/**
 * @author kohachiro
 *
 */
public class UserPropertyUpdateRequestHandler {

	/**
	 * 
	 */
	//@Override
	public static int invoke(Object data, Object channel)  throws Exception {
		System.out.println("["+channel.hashCode()+"]["+Protocol.MessageHandler.UserPropertyUpdateRequest_VALUE+"]UserPropertyUpdateRequest");
		UserPropertyUpdateRequestData property=((UserPropertyUpdateRequestData)data);
		if (property.getName()!="" && property.getValue()!=""){
			Properties properties=new Properties(channel.hashCode());
			properties.addProperty(property.getName(), property.getValue());
			User user=User.get(channel);
			user.getRoom().userPropertyNotice(properties, user.getId());
		}
		return Protocol.MessageHandler.UserPropertyUpdateRequest_VALUE;
	}
}
